// 所有的api请求
import requests from './request'
// --- 菜单管理
// 菜单添加
export const addMenu = (info) => requests({ url: '/menuadd', method: 'post', data: info })
// 获取菜单列表
export const getMenuList = () => requests({ url: '/menulist', method: 'get' })
// 获取一条菜单
export const getOneMenu = (id) => requests({ url: `/menuinfo/${id}`, method: 'get' })
// 菜单修改
export const editMenu = (info) => requests({ url: '/menuedit', method: 'post', data: info })
// 菜单删除
export const delMenuById = (id) => requests({ url: '/menudelete', method: 'post', data: { id } })

// --- 角色管理
// 角色删除
export const delRoleById = (id) => requests({ url: '/roledelete', method: 'post', data: { id } })
// 角色添加
export const addRole = (data) => requests({ url: '/roleadd', method: 'post', data })
// 角色修改
export const editRole = (data) => requests({ url: '/roleedit', method: 'post', data })
// 获取角色列表
export const getRoleList = () => requests({ url: '/rolelist', method: 'get' })
// 获取一条角色
export const getOneRole = (id) => requests({ url: `/roleinfo/${id}`, method: 'get' })

// ---管理员管理
// 获取管理员总数
export const getUserCount = () => requests({ url: '/usercount', method: 'get' })
// 获取管理员列表
export const getUserList = (data) => requests.get('/userlist', { params: data })
// 新增管理员
export const addUser = (data) => requests.post('/useradd', data)
// 管理员删除
export const delUserById = (id) => requests.post('/userdelete', { id })
// 管理员修改
export const editUser = (data) => requests({ url: '/useredit', method: 'post', data })
// 后台管理员登录
export const userLogin = (data) => requests.post('/userlogin', data)
// 获取树形商品分类列表
export const getCateListTree = () => requests('/catelist', { params: { istree: 1 } })
// 新增商品分类
export const addCate = (data) => requests.post('/cateadd', data)
// 商品删除
export const delCateById = (id) => requests.post('/catedelete', { id })
// 商品修改
export const editCate = (data) => requests({ url: '/cateedit', method: 'post', data })

// 新增商品规格
export const addSpecs = (data) => requests.post('/specsadd', data)
// 获取商品规格总数
export const getSpecsCount = () => requests({ url: '/specscount', method: 'get' })
// 获取商品规格列表
export const getSpecsList = (data) => requests.get('/specslist', { params: data })
// 商品规格删除
export const delSpecsById = (id) => requests.post('/specsdelete', { id })
// 商品规格修改
export const editSpecs = (data) => requests({ url: '/specsedit', method: 'post', data })

// 商品管理添加
export const addGoods = (data) => requests.post('/goodsadd', data)
// 商品总数
export const getGoodsCount = () => requests.get('/goodscount')
// 商品管理列表
export const getGoodsList = (data) => requests.get('/goodslist', { params: data })
// 商品管理修改
export const editGoods = (data) => requests.post('/goodsedit', data)
// 商品管理添加
export const delGoods = (id) => requests.post('/goodsadd', { id })
// 根据上级分类，获取下级分类
export const getCateListByTop = (data) => requests('/catelist', { params: data })
